//聚订单-询盘列表
function jdd_list() {
    new Vue({
        el: "#jdd_list",
        data() {
            return {
                crumblist: [{
                    'href': '',
                    'text': '首页'
                }, {
                    'href': '',
                    'text': '聚订单'
                }, {
                    'href': '',
                    'text': '询盘列表'
                }],
                ordertype: [{
                    'txt': '全部',
                    'val': '0'
                }, {
                    'txt': '服饰加工',
                    'val': '1'
                }, {
                    'txt': '面料采购',
                    'val': '2'
                }, {
                    'txt': '辅料采购',
                    'val': '3'
                }],
                loginName: '',
                list: null,
                total: 0,
                pageNo: 1,
                pageSize: 12,
                typeId: 0,
                areaId: 0,
                typeList: [{
                    'name': '服饰加工',
                    'number': '1'
                }, {
                    'name': '面料采购',
                    'number': '2'
                }, {
                    'name': '辅料采购',
                    'number': '3'
                }],
                areaList: [],
                orderType: null,
                value1: '',
                categoryId:''
            }
        },
        methods: {
            getData() {
                let that = this;
                axios.get(urlParam.domain() + '/api/order/order/enquiryList', {
                    params: {
                        pageNo: that.pageNo,
                        pageSize: that.pageSize,
                        orderType: that.orderType,
                        area: that.areaId,
                        categoryId:that.categoryId,
                        token: urlParam.token()
                    }
                }).then(function(response) {
                    that.list = response.data.data.list;
                    that.total = Math.ceil(response.data.data.total / that.pageSize);
                });
            },
            getListByArea: function() {
                this.getData();
            },
            listen: function(data) {
                // 翻页事件
                //alert('当前页码：' + data);
                this.pageNo = data;
                this.getData();
            },
            //获取地区集合
            getAreaData() {
                let that = this;
                axios.get(urlParam.domain() + '/api/dict/query', {
                    params: {
                        name: '地区',
                        token: urlParam.token()
                    }
                }).then(function(response) {
                    that.areaList = response.data.data;
                });
            }
        },
        created() {
            var reqParams = globalAPI.getRequest();
            if(reqParams){
                this.orderType = reqParams.orderType;
                this.categoryId = reqParams.categoryId;
            }
            this.getAreaData();
            this.getData();
            var myDate = new Date();
            var today = myDate.toLocaleDateString();
            this.value1 = today;
        },
        watch:{
            typeId(){
                if (this.typeId == 0) {
                    this.orderType = null;
                } else {
                    this.orderType = this.typeId;
                }
                this.getData();
            }
        }
    });
}

//聚服务-发布询盘
function jdd_xunpan() {
    new Vue({
        el: "#jdd_xunpan",
        data() {
            return {
                activeName: '1',
                mark: null, //详细说明
                area: null,
                gongyi: 1,
                gongyiValue: 1,
                showBtnSons: false, // 是否显示工艺类别悬浮窗
                gongyitype:[],
                gongyilist:[],
                hezuolist: [],
                xiaoshoulist: [],
                diqulist: [],
                unitList:[],
                diqu1:null,
                diqu2:null,
                diqu3:null,
                hezuotype: null,
                xiaoshoutype: null,
                imgDescribe1: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                imgDescribe2: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                imgDescribe3: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                imgDescribe4: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                imgDescribe5: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                shuiprice: null,
                showunit: false,
                dress:{},
                material:{},
                accessories:{},
                orderType:1,
                materialCategoryId:null,
                accessoriesCategoryId:null,
                materialCatagoryList:[],
                childMaterialCatagoryList:[],
                accessoriesCatagoryList:[],
                childAccessoriesCatagoryList:[],
                companyId:null
            }
        },
        methods: {
            getData() {
                let that = this;

                //查询区域
                axios.get(urlParam.domain() + '/api/dict/query', {
                    params: {
                        name: "地区",
                    }
                })
                .then(function(response) {
                    that.diqulist = response.data.data;

                });

                //查询合作方式
                axios.get(urlParam.domain() + '/api/dict/query', {
                    params: {
                        name: "合作方式",
                    }
                })
                .then(function(response) {
                    that.hezuolist = response.data.data;

                });

                //查询销售市场    
                axios.get(urlParam.domain() + '/api/dict/query', {
                    params: {
                        name: "销售市场",
                    }
                })
                .then(function(response) {
                    that.xiaoshoulist = response.data.data;

                });

                //查询订单单位
                axios.get(urlParam.domain() + '/api/dict/query', {
                    params: {
                        name: "订单单位",
                    }
                })
                .then(function(response) {
                    that.unitList = response.data.data;

                });
                this.dressCategory();
                this.materialsCategory();
                this.accessoriesCategory();

            },
            // 选择工艺类别
            chooseGongyi(val) {
                if(this.orderType==1){
                    this.gongyi = val.id;
                    this.gongyilist=val.child;
                    if(this.gongyilist!=null && this.gongyilist.length>0){
                        this.showBtnSons = true;
                    }else{
                        this.showBtnSons = false;
                        this.dress.categoryId=val.id;
                        this.dress.categoryName=val.name;
                    }
                }else if(this.orderType==2){
                    this.materialCategoryId = val.id;
                    this.childMaterialCatagoryList=val.childrenList;
                    if(this.childMaterialCatagoryList!=null && this.childMaterialCatagoryList.length>0){
                        this.showBtnSons = true;
                    }else{
                        this.showBtnSons = false;
                        this.material.categoryId=val.id;
                        this.material.categoryName=val.name;
                    }
                }else{
                    this.accessoriesCategoryId = val.id;
                    this.childAccessoriesCatagoryList=val.childrenList;
                    if(this.childAccessoriesCatagoryList!=null && this.childAccessoriesCatagoryList.length>0){
                        this.showBtnSons = true;
                    }else{
                        this.showBtnSons = false;
                        this.accessories.categoryId=val.id;
                        this.accessories.categoryName=val.name;
                    }
                }

            },
            chooseChildCategory(val) {
                if(this.orderType==1){
                    this.dress.categoryId=val.id;
                    this.dress.categoryName=val.name;
                    this.showBtnSons = false;
                }else if(this.orderType==2){
                    if(val.childrenList!=null && val.childrenList.length>0){
                        this.showBtnSons = true;
                    }else{
                        this.material.categoryId=val.id;
                        this.material.categoryName=val.name;
                        this.showBtnSons = false;
                    }
                }else{
                    if(val.childrenList!=null && val.childrenList.length>0){
                        this.showBtnSons = true;
                    }else{
                        this.accessories.categoryId=val.id;
                        this.accessories.categoryName=val.name;
                        this.showBtnSons = false;
                    }
                }
            },
            // 选择合作方式
            chooseHezuoType(val) {
                this.hezuotype = val.number;
                this.dress.cooperation=val.number;
                this.dress.cooperationName=val.name;
                this.dress.cooperation=val.number;
            },
            // 选择销售市场
            chooseXiaoshouType(val) {
                this.xiaoshoutype = val.number;
                this.dress.salesMarket=val.number;
                this.dress.salesMarketName=val.name;
            },
            chooseDiqu(val) {
                if(this.orderType==1){
                    this.diqu1=val.number;
                    this.dress.area=val.number;
                    this.dress.areaName=val.name;
                    console.log(this.dress.areaName);
                }else if(this.orderType==2){
                    this.diqu2=val.number;
                    this.material.area=val.number;
                    this.material.areaName=val.name;
                }else{
                    this.diqu3=val.number;
                    this.accessories.area=val.number;
                    this.accessories.areaName=val.name;
                }
            },
            // 含税价单位选择
            chooseUnit(val) {
                if(this.orderType==1){
                    this.dress.unit=val.number;
                    this.dress.unitName=val.name;
                }else if(this.orderType==2){
                    this.material.unit=val.number;
                    this.material.unitName=val.name;
                }else{
                    this.accessories.unit=val.number;
                    this.accessories.unitName=val.name;
                }
                this.showunit = !this.showunit;
            },
            // 显示/隐藏单位
            toggleshowunit() {
                this.showunit = !this.showunit;
            },
            // 关闭工艺类别悬浮窗
            closeBtnSons() {
                this.showBtnSons = false;
            },
            handleClick(tab, event) {
                if(this.orderType!=parseInt(tab.index)+1){
                    this.orderType=parseInt(tab.index)+1;
                }
            },
            formatDate(){
                if(this.orderType==1){
                    if(this.dress.deliveryDate!=undefined){
                        this.dress.deliveryDate = formatNormal(this.dress.deliveryDate, 0);
                    }
                    if(this.dress.deadline!=undefined){
                        this.dress.deadline = formatNormal(this.dress.deadline, 0);
                    }
                }else if(this.orderType==2){
                    if(this.material.deliveryDate!=undefined){
                        this.material.deliveryDate = formatNormal(this.material.deliveryDate, 0);
                    }
                    if(this.material.deadline!=undefined){
                        this.material.deadline = formatNormal(this.material.deadline, 0);
                    }
                }else{
                    if(this.accessories.deliveryDate!=undefined){
                        this.accessories.deliveryDate = formatNormal(this.accessories.deliveryDate, 0);
                    }
                    if(this.accessories.deadline!=undefined){
                        this.accessories.deadline = formatNormal(this.accessories.deadline, 0);
                    }
                }
            },
            dressCategory(){
                //服饰加工工艺类别
                let that=this;
                axios.get(urlParam.domain() + '/api/order/dressCategory/listAll', {
                    params: {
                    }
                })
                .then(function(response) {
                    that.gongyitype=response.data.data;
                    console.log(that.gongyitype);
                });
            },
            materialsCategory(){
                let that=this;
                axios.get(urlParam.domain() + '/api/order/materialCategory/listAll', {
                    params: {
                    }
                })
                .then(function(response) {
                    that.materialCatagoryList=response.data.data;
                    console.log(that.materialCatagoryList);
                });
            },
            accessoriesCategory(){
                let that=this;
                axios.get(urlParam.domain() + '/api/order/accessoriesCategory/listAll', {
                    params: {
                    }
                })
                .then(function(response) {
                    that.accessoriesCatagoryList=response.data.data;
                });
            },
            sendDress(){
                //发布服饰加工
                this.dress.status=0;
                this.dress.companyId=this.companyId;
				this.dress.picList=[];
				for(let url of this.imgDescribe1.url){
					var obj={};
					obj.fileUrl=url;
                    this.dress.picList.push(obj);
				}
                let that=this;
                axios.post(
                    urlParam.domain() + '/api/order/dress/add',
                    JSON.stringify(that.dress),
                    {
                        headers: { "token": urlParam.token(), "Content-Type": "application/json" }
                    }
                    )
                .then(result =>  {
                    if(result.data.code==1){
                        this.$message({
                            message: '发布成功',
                            type: 'success'
                        });
                        window.location.href = '../jdingdan/list.html';
                    }else{
                        this.$message.error('发布失败');
                    }
                });
            },
            sendMaterial(){
                //发布面料采购
                this.material.status=0;
                this.material.companyId=this.companyId;
                this.material.picList=[];
                for(let url of this.imgDescribe2.url){
                    var obj={};
                    obj.fileUrl=url;
                    this.material.picList.push(obj);
                }
                for(let url of this.imgDescribe3.url){
                    var obj={};
                    obj.fileUrl=url;
                    this.material.picList.push(obj);
                }
                let that=this;
                axios.post(
                    urlParam.domain() + '/api/order/material/add',
                    JSON.stringify(that.material),
                    {
                        headers: { "token": urlParam.token(), "Content-Type": "application/json" }
                    }
                )
                .then(result =>  {
                    if(result.data.code==1){
                        this.$message({
                            message: '发布成功',
                            type: 'success'
                        });
                        window.location.href = '../jdingdan/list.html';
                    }else{
                        this.$message.error('发布失败');
                    }

                });
            },
            sendAccessories(){
                //发布辅料采购
                this.accessories.status=0;
                this.accessories.companyId=this.companyId;
                this.accessories.picList=[];
                for(let url of this.imgDescribe4.url){
                    var obj={};
                    obj.fileUrl=url;
                    this.material.picList.push(obj);
                }
                for(let url of this.imgDescribe5.url){
                    var obj={};
                    obj.fileUrl=url;
                    this.material.picList.push(obj);
                }
                let that=this;
                axios.post(
                    urlParam.domain() + '/api/order/accessories/add',
                    JSON.stringify(that.accessories),
                    {
                        headers: { "token": urlParam.token(), "Content-Type": "application/json" }
                    }
                )
                .then(result =>  {
                    if(result.data.code==1){
                        this.$message({
                            message: '发布成功',
                            type: 'success'
                        });
                        window.location.href = '../jdingdan/list.html';
                    }else{
                        this.$message.error('发布失败');
                    }
                });
            }
        },
        created() {
            var reqParams = globalAPI.getRequest();
            if(reqParams){
                this.companyId=reqParams.companyId;
            }
            this.getData();
        }
    });
}



//服饰加工-报价详情
function jdd_baojia1() {
    new Vue({
        el: "#jdd_baojia",
        data() {
            return {
                'crumblist': [{
                    'href': '../index/index1.html',
                    'text': '首页'
                }, {
                    'href': '../jdingdan/list.html',
                    'text': '聚订单'
                }, {
                    'href': '../jdingdan/list.html',
                    'text': '询盘列表'
                }, {
                    'href': '',
                    'text': '服饰加工详情'
                }],
                diqu: null, //所在地区
                baozhuang: null,
                yunshu: null,
                shuiprice: null,
                showunit: false,
                unitName: '',
                guigetype: null,
                packing: [],
                transport: [],
                quotation:{},
                buyUserInfo:{},
                companyInfo:{},
                dress:{},
                dressQuotationList:[],
                attachmentList:[],
                order:{},
                offerId:'',
                orderId:'',
                companyName:''
            }
        },
        methods: {
            getData() {
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/order/dressquotation/toAdd',
                    responseType: 'stream',
                    data: formartPostParms({
                        orderId:that.orderId,
                        offerId:that.offerId,
                        token:urlParam.token()
                    }),
                }).then(function(response) {
                    console.log(response.data);
                    if(response.data.code==1){
                        that.packing=response.data.data.packing;
                        that.transport=response.data.data.transport;
                        that.dress=response.data.data.dress;
                        that.quotation.dressId=that.dress.id;
                        that.companyInfo=response.data.data.companyInfo;
                        that.buyUserInfo=response.data.data.buyUserInfo;
                        that.dressQuotationList=response.data.data.dressQuotationList;
                        that.attachmentList=response.data.data.attachmentList;
                        that.order=response.data.data.order;
                        that.companyName=response.data.data.companyName;
                        if(response.data.data.quotation!=undefined&&response.data.data.quotation!=null){
                            that.quotation=response.data.data.quotation;
                            that.baozhuang=that.quotation.packing;
                            that.yunshu=that.quotation.transport;
                        }
                    }
                });

            },
            submitQuotation: function() {
                if (this.quotation.companyScale == null || this.quotation.companyScale == '') {
                    this.$notify.error({
                        title: '错误',
                        message: '工厂规模不可为空'
                    });
                    return;
                } else if(this.quotation.total == null || this.quotation.total == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '含税单价不可为空'
                    });
                    return;
                }else if(this.quotation.packing == null || this.quotation.packing == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择包装方式'
                    });
                    return;
                }else if(this.quotation.transport == null || this.quotation.transport == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择运输方式'
                    });
                    return;
                }else {
                    let that=this;
                    axios.post(
                        urlParam.domain() + '/api/order/dressquotation/add',
                        JSON.stringify(that.quotation),
                        {
                            headers: { "token": urlParam.token(), "Content-Type": "application/json" }
                        }
                    )
                        .then(result =>  {
                            if(result.data.code==1){
                                this.$message({
                                    message: '发布成功',
                                    type: 'success'
                                });
                                window.location.href = '../jdingdan/list.html';
                            }else{
                                this.$message.error('发布失败');
                            }
                        });
                }
            },
            // 包装方式选择
            chooseBaozhuang(val) {
                this.baozhuang = val;
                this.quotation.packing=val;
            },
            // 运输方式选择
            chooseYunshu(val) {
                this.yunshu = val;
                this.quotation.transport=val;
            },
            // 含税价单位选择
            chooseUnit(val) {
                this.unitName = val.name;
                this.showunit = !this.showunit;
                this.quotation.unit=val.number;
            },
            // 显示/隐藏单位
            toggleshowunit() {
                this.showunit = !this.showunit;
            },
            // 现货/预定选择
            chooseGuigeType(val) {
                this.guigetype = val;
                this.quotation.source=val;//1现货,2预定
            }
        },
        created() {
            var reqParams = globalAPI.getRequest();
            if(reqParams){
                this.orderId = reqParams.orderId;
                if(reqParams.offerId!=undefined&&reqParams.offerId!=null){
                    this.offerId = reqParams.offerId;
                }
                console.log("***"+this.offerId);
            }
            this.getData();
        }
    });
}

//面料采购-报价详情
function jdd_baojia2() {
    new Vue({
        el: "#jdd_baojia",
        data() {
            return {
                'crumblist': [{
                    'href': '',
                    'text': '首页'
                }, {
                    'href': '',
                    'text': '聚订单'
                }, {
                    'href': '',
                    'text': '询盘列表'
                }, {
                    'href': '',
                    'text': '面料采购详情'
                }],

                diqu: null, //所在地区
                baozhuang: null,
                yunshu: null,
                shuiprice: null,
                showunit: false,
                unitName: '',
                guigetype: null,
                unit:[],
                packing: [],
                transport: [],
                quotation:{},
                buyUserInfo:{},
                companyInfo:{},
                material:{},
                materialQuotationList:[],
                attachmentList:[],
                order:{},
                imgDescribe: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                orderId:'',
                offerId:''
            }
        },
        methods: {
            getData() {
                let href = window.location.href;
                let split = href.split("=");
                this.quotation.materialId = split[1];
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/order/materialquotation/toAdd',
                    responseType: 'stream',
                    data: formartPostParms({
                        orderId:that.orderId,
                        offerId:that.offerId,
                        token:urlParam.token()
                    }),
                }).then(function(response) {
                    console.log(response.data);
                    if(response.data.code==1){
                        that.packing=response.data.data.packing;
                        that.source=response.data.data.source;
                        that.transport=response.data.data.transport;
                        that.unit=response.data.data.unit;
                        that.material=response.data.data.material;
                        that.quotation.materialId=that.material.id;
                        that.companyInfo=response.data.data.companyInfo;
                        that.buyUserInfo=response.data.data.buyUserInfo;
                        that.materialQuotationList=response.data.data.materialQuotationList;
                        that.attachmentList=response.data.data.attachmentList;
                        that.order=response.data.data.order;
                        if(response.data.data.quotation!=undefined&&response.data.data.quotation!=null){
                            that.quotation=response.data.data.quotation;
                            that.baozhuang=that.quotation.packing;
                            that.yunshu=that.quotation.transport;
                            that.guigetype=that.quotation.source;
                        }
                        if(response.data.data.quotationAttachmentList!=undefined&&response.data.data.quotationAttachmentList!=null){
                            that.imgDescribe.url=[];
                            for(let obj of response.data.data.quotationAttachmentList){
                                that.imgDescribe.url.push(obj.fileUrl);
                            }
                        }
                    }
                });

            },
            submitQuotation: function() {
                if (this.quotation.total == null || this.quotation.total == '') {
                    this.$notify.error({
                        title: '错误',
                        message: '含税价不可为空'
                    });
                    return;
                } else if(this.quotation.unit == null || this.quotation.unit == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择单位'
                    });
                    return;
                }else if(this.quotation.packing == null || this.quotation.packing == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择包装方式'
                    });
                    return;
                }else if(this.quotation.transport == null || this.quotation.transport == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择运输方式'
                    });
                    return;
                }else if(this.quotation.source == null || this.quotation.source == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择商品商品是现货还是预定'
                    });
                    return;
                }else {
                    this.quotation.picList=[];
                    for(let url of this.imgDescribe.url){
                        var obj={};
                        obj.fileUrl=url;
                        this.quotation.picList.push(obj);
                    }
                    let that=this;
                    axios.post(
                        urlParam.domain() + '/api/order/materialquotation/add',
                        JSON.stringify(that.quotation),
                        {
                            headers: { "token": urlParam.token(), "Content-Type": "application/json" }
                        }
                    )
                        .then(result =>  {
                            if(result.data.code==1){
                                this.$message({
                                    message: '发布成功',
                                    type: 'success'
                                });
                                window.location.href = '../jdingdan/list.html';
                            }else{
                                this.$message.error('发布失败');
                            }
                        });
                }
            },
            // 包装方式选择
            chooseBaozhuang(val) {
                this.baozhuang = val;
                this.quotation.packing=val;
            },
            // 运输方式选择
            chooseYunshu(val) {
                this.yunshu = val;
                this.quotation.transport=val;
            },
            // 含税价单位选择
            chooseUnit(val) {
                this.unitName = val.name;
                this.showunit = !this.showunit;
                this.quotation.unit=val.number;
            },
            // 显示/隐藏单位
            toggleshowunit() {
                this.showunit = !this.showunit;
            },
            // 现货/预定选择
            chooseGuigeType(val) {
                this.guigetype = val;
                this.quotation.source=val;//1现货,2预定
            }
        },
        created() {
            var reqParams = globalAPI.getRequest();
            if(reqParams){
                this.orderId = reqParams.orderId;
                if(reqParams.offerId!=undefined&&reqParams.offerId!=null){
                    this.offerId = reqParams.offerId;
                }
            }
            this.getData();
        }
    });
}

//辅料采购-报价详情
function jdd_baojia3() {
    new Vue({
        el: "#jdd_baojia",
        data() {
            return {
                'crumblist': [{
                    'href': '',
                    'text': '首页'
                }, {
                    'href': '',
                    'text': '聚订单'
                }, {
                    'href': '',
                    'text': '询盘列表'
                }, {
                    'href': '',
                    'text': '辅料采购详情'
                }],
                diqu: null, //所在地区
                baozhuang: null,
                yunshu: null,
                shuiprice: null,
                showunit: false,
                unitName: '',
                guigetype: null,
                unit:[],
                packing: [],
                transport: [],
                quotation:{},
                buyUserInfo:{},
                companyInfo:{},
                accessories:{},
                accessoriesQuotationList:[],
                attachmentList:[],
                order:{},
                imgDescribe: { //企业 logo
                    base64: [""], //企业 logo base64码 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                orderId:'',
                offerId:''
            }
        },
        methods: {
            getData() {
                let that = this;
                axios({
                    method: 'post',
                    url: urlParam.domain() + '/api/order/accessoriesquotation/toAdd',
                    responseType: 'stream',
                    data: formartPostParms({
                        orderId:that.orderId,
                        offerId:that.offerId,
                        token:urlParam.token()
                    }),
                }).then(function(response) {
                    if(response.data.code==1){
                        that.packing=response.data.data.packing;
                        that.source=response.data.data.source;
                        that.transport=response.data.data.transport;
                        that.unit=response.data.data.unit;
                        that.accessories=response.data.data.accessories;
                        that.quotation.accessoriesId=that.accessories.id;
                        that.companyInfo=response.data.data.companyInfo;
                        that.buyUserInfo=response.data.data.buyUserInfo;
                        that.accessoriesQuotationList=response.data.data.accessoriesQuotationList;
                        that.attachmentList=response.data.data.attachmentList;
                        that.order=response.data.data.order;
                        if(response.data.data.quotation!=undefined&&response.data.data.quotation!=null){
                            that.quotation=response.data.data.quotation;
                            for (let obj of that.unit) {
                                if(obj.number==that.quotation.unit){
                                    that.unitName=obj.name;
                                    break;
                                }
                            }
                            that.baozhuang=that.quotation.packing;
                            that.yunshu=that.quotation.transport;
                        }
                        if(response.data.data.quotationAttachmentList!=undefined&&response.data.data.quotationAttachmentList!=null){
                            that.imgDescribe.url=[];
                            for(let obj of response.data.data.quotationAttachmentList){
                                that.imgDescribe.url.push(obj.fileUrl);
                            }
                        }
                    }
                });

            },
            submitQuotation: function() {
                if (this.quotation.utilPrice == null || this.quotation.utilPrice == '') {
                    this.$notify.error({
                        title: '错误',
                        message: '含税价不可为空'
                    });
                    return;
                } else if(this.quotation.unit == null || this.quotation.unit == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择单位'
                    });
                    return;
                }else if(this.quotation.packing == null || this.quotation.packing == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择包装方式'
                    });
                    return;
                }else if(this.quotation.transport == null || this.quotation.transport == ''){
                    this.$notify.error({
                        title: '错误',
                        message: '请选择运输方式'
                    });
                    return;
                }else {
                    this.quotation.picList=[];
                    for(let url of this.imgDescribe.url){
                        var obj={};
                        obj.fileUrl=url;
                        this.quotation.picList.push(obj);
                    }
                    let that=this;
                    axios.post(
                        urlParam.domain() + '/api/order/accessoriesquotation/add',
                        JSON.stringify(that.quotation),
                        {
                            headers: { "token": urlParam.token(), "Content-Type": "application/json" }
                        }
                    )
                        .then(result =>  {
                            if(result.data.code==1){
                                this.$message({
                                    message: '发布成功',
                                    type: 'success'
                                });
                                window.location.href = '../jdingdan/list.html';
                            }else{
                                this.$message.error('发布失败');
                            }
                        });
                }
            },
            // 包装方式选择
            chooseBaozhuang(val) {
                this.baozhuang = val;
                this.quotation.packing=val;
            },
            // 运输方式选择
            chooseYunshu(val) {
                this.yunshu = val;
                this.quotation.transport=val;
            },
            // 含税价单位选择
            chooseUnit(val) {
                this.unitName = val.name;
                this.showunit = !this.showunit;
                this.quotation.unit=val.number;
            },
            // 显示/隐藏单位
            toggleshowunit() {
                this.showunit = !this.showunit;
            }
        },
        created() {
            var reqParams = globalAPI.getRequest();
            if(reqParams){
                this.orderId = reqParams.orderId;
                if(reqParams.offerId!=undefined&&reqParams.offerId!=null){
                    this.offerId = reqParams.offerId;
                }
            }
            this.getData();
        }
    });
}